#!/bin/sh


freeze() {
    pip freeze > requirements-fre.txt
}


dev_run() {
    uvicorn main:app --port=8068 --reload
}


docker_build() {
    _svr_name = gpts_api
    _build_time = $(shell date +%y%m%d%H%M%S) 
    _image_name = ${_svr_name}:v${_build_time}

    docker build -f deploy/Dockerfile -t ${_image_name} .
}


docker_run() {
    docker run -d -p 8068:8068 -v /path/.env:/app/.env gpts_api:v1
}








case "$1" in
   'dev_run')
        dev_run
    ;;
   'freeze')
        freeze
    ;;
    'docker_build')
        docker_build
    ;;
    'docker_build')
        docker_build
    ;;
    'docker_run')
        docker_run
    ;;
  *)
     echo "Usage: run.sh {docker_build | docker_run | dev_run | freeze}"
     exit 1
esac
